<?php

/**
 * ayudante actions.
 *
 * @package    sayd
 * @subpackage ayudante
 * @author     hylianred
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ayudanteActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executeLogout(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->getUser()->setAuthenticated(false);
        $this->getUser()->getAttributeHolder()->clear();
        $this->redirect("@homepage");
    }
  }
  
  public function executeClases(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executeAsistencias(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executeCalificaciones(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executeContenidos(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executeHorarios(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executeUbicaciones(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executeComentarios(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executePerfil(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
  
  public function executeMensajes(sfWebRequest $request){
    if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        
        $statement = Doctrine_Manager::getInstance()->connection();
        $results = $statement->execute("SELECT * FROM mensajes_recibidos_ayudante,usuario_ayudante
                                                 WHERE mensajes_recibidos_ayudante.id_usuario = usuario_ayudante.id_usuario 
                                                 AND seudonimo_usuario = '".$this->getUser()->getAttribute('nick',null)."'
                                                 ORDER BY fecha DESC");
        $result = $results->fetchAll();
        //llevar al layout este array
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    }
  }
    
  public function executeModificar_calificaciones(sfWebRequest $request){
     if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    } 
  }
  
  public function executeModificar_horario(sfWebRequest $request){
     if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    } 
  }
  
  public function executeModificar_ubicacion(sfWebRequest $request){
     if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    } 
  }
  
  public function executeModificar_perfil(sfWebRequest $request){
     if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    } 
  }
  
  public function executeNuevo_mensaje(sfWebRequest $request){
     if (!$this->getUser()->isAuthenticated()){
        $this->forward404();
    }else{
        $this->setLayout('layout_ayudante');
        $this->getRequest()->setAttribute('user', $this->getUser()->getAttribute('user',null));
        $this->getRequest()->setAttribute('user_a', $this->getUser()->getAttribute('user_a',null));
        $this->getRequest()->setAttribute('nick', $this->getUser()->getAttribute('nick',null));
    } 
  }
}
